

#ifndef _DEVFS_H
#define _DEVFS_H

#include <types.h>
#include <fd_types.h>





/**
 * device type.
 */
typedef enum _device_type_t{
	CHARDEV,
	BLKDEV
} device_type_t;

typedef int (*chardev_read_t)(open_file_descriptor *,void*, __u32);
typedef int (*chardev_write_t)(open_file_descriptor *, const void*, __u32);
typedef int (*chardev_ioctl_t) (open_file_descriptor*, unsigned int, void*);
typedef int (*chardev_open_t) (open_file_descriptor*);
typedef int (*chardev_close_t) (open_file_descriptor*);


typedef struct {
	chardev_read_t read; 
	chardev_write_t write; 
	chardev_ioctl_t ioctl; 
	chardev_open_t open; 
	chardev_close_t close; 
	void * custom_data; 
} chardev_interfaces;


typedef int (*blkdev_read_t)(open_file_descriptor *,void*, __u32, __u64);
typedef int (*blkdev_write_t)(open_file_descriptor *, const void*, __u32, __u64);
typedef int (*blkdev_ioctl_t) (open_file_descriptor*, unsigned int, void*);
typedef int (*blkdev_open_t) (open_file_descriptor*);
typedef int (*blkdev_close_t) (open_file_descriptor*);


typedef struct {
	blkdev_read_t read; 
	blkdev_write_t write; 
	blkdev_ioctl_t ioctl; 
	blkdev_open_t open; 
	blkdev_close_t close; 
	void * custom_data;
} blkdev_interfaces;

#ifdef DEVFS_C  
extern int devfs_register_blkdev( const char* name, blkdev_interfaces* di, struct fs_dev_id_t *dev_id);
extern int devfs_register_chardev(const char* name, chardev_interfaces* di, struct fs_dev_id_t *dev_id);
#else

#endif



void devfs_init();



#endif 


